<template>
  <div>
    <h1>注册用户</h1>
    <p>用户名:<input type="text" v-model="username"></p>
    <p>密码:<input type="text" v-model="password"></p>
    <p>确认密码:<input type="text" v-model="password2"></p>
    <p>邮箱:<input type="text" v-model="user_email"></p>
    <input type="button" value="注册" @click="add_user">
  </div>
</template>

<script>
import axios from 'axios'
export default {

  data () {
    return {
        username:'',
        password:'',
        password2:'',
        user_email:''
    }
  },

  methods: {
      add_user(){
          let form_data=new FormData()
          form_data.append('username',this.username)
          form_data.append('password',this.password)
          form_data.append('password2',this.password2)
          form_data.append('email',this.user_email)
          axios({
              url:'http://127.0.0.1:8000/app01/userapi/',
              method:'post',
              data:form_data
          }).then(resp=>{
              console.log(resp)
          })
      }

  },
  created(){}
}
</script>